<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v_model绑定checkbox</title>
</head>
<body>
  <div id="app">
    <!--1. checkbox单选框: 绑定到属性中的值是一个布尔值-->
    <label for="agree">
      <input id="agree" type="checkbox" v-model="isAgree"> 同意协议
    </label>
    <h2>单选框{{isAgree}}</h2>

    <!--2. checkbox多选框: 保存到属性中Array-->
    <!--注意: 多选框中,必须明确的绑定一个value值-->
    <div class="hobbies">
      <h2>请选择你的爱好: </h2>
      <label for="sing">
        <input id="sing" type="checkbox" v-model="hobbies" value="sing"> 唱 <!--也可以写成: value="任意key"-->
      </label>
      <label for="dance">
        <input id="dance" type="checkbox" v-model="hobbies" value="dance"> 跳
      </label>
      <label for="rap">
        <input id="rap" type="checkbox" v-model="hobbies" value="rap"> rap
      </label>
      <label for="basketball">
        <input id="bastkeball" type="checkbox" v-model="hobbies" value="bastkeball"> 篮球
      </label>
      <h2>已选爱好: {{hobbies}}</h2>
    </div>
  </div>
  <script src="../lib/vue.js"></script>
  <script>
    // 使用vue
    const app = Vue.createApp({
      data: function(){
        return {
          isAgree: false, // 如果首次绑定的是 isAgree: "aaa"  是一个非布尔值,那么在点击按钮后,还是会被重新赋值布尔值 
          hobbies: []
        }
      }
      ,methods: {
      },
      computed: {
        
      },
      watch: {
       
      }
    }
    )
    // 挂载 
    app.mount("#app")
  </script>

</body>
</html>
